<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="学员姓名" prop="learnerName">
        <el-input
          v-model="queryParams.learnerName"
          placeholder="请输入学员姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="电话号" prop="iphone">
        <el-input
          v-model="queryParams.iphone"
          placeholder="请输入电话号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="民族" prop="nationality">
        <el-input
          v-model="queryParams.nationality"
          placeholder="请输入民族"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="性别" prop="gender">
        <el-select v-model="queryParams.gender" placeholder="请选择性别" clearable>
          <el-option
            v-for="dict in dict.type.sys_user_sex"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="证件类型" prop="documentType">
        <el-select v-model="queryParams.documentType" placeholder="请选择证件类型" clearable>
          <el-option
            v-for="dict in dict.type.document_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="证件号码" prop="documentNumber">
        <el-input
          v-model="queryParams.documentNumber"
          placeholder="请输入证件号码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="出生日期">
        <el-date-picker
          v-model="daterangeDateOfBirth"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="居住地址" prop="residentialAddress">
        <el-input
          v-model="queryParams.residentialAddress"
          placeholder="请输入居住地址"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="报名时间">
        <el-date-picker
          v-model="daterangeRegistrationTime"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item label="档案归属" prop="fileAttribution">
        <el-select v-model="queryParams.fileAttribution" placeholder="请选择档案归属" clearable>
          <el-option
            v-for="dict in dict.type.file_attribution"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="介绍人" prop="userId">
        <el-select v-model="queryParams.userId" placeholder="请选择介绍人" clearable>
          <el-option
            v-for="item in userList"
            :key="item.userId"
            :label="`${item.nickName}(${item.phonenumber})`"
            :value="item.userId">
            <span style="float: left">{{ item.nickName }}</span>
            <span style="float: right; color: #8492a6; font-size: 13px">{{ item.phonenumber }}</span>
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="报名车型" prop="registeredModels">
        <el-select v-model="queryParams.registeredModels" placeholder="请选择报名车型" clearable>
          <el-option
            v-for="dict in dict.type.registered_models"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="招生来源" prop="sourceOfEnrollment">
        <el-select v-model="queryParams.sourceOfEnrollment" placeholder="请选择招生来源" clearable>
          <el-option
            v-for="dict in dict.type.source_of_enrollment"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>

      <el-form-item label="班制" prop="classTypeId">
        <el-select ref='classType' v-model="queryParams.classTypeId" placeholder="请选择班制" clearable>
          <el-option
            v-for="item in classTypeList"
            :key="item.id"
            :label="`${item.className}(${item.price})`"
            :value="item.id">
            <span style="float: left">{{ item.className }}</span>
            <span style="float: right; color: #8492a6; font-size: 13px">{{ item.price + '元' }}</span>
          </el-option>
        </el-select>
      </el-form-item>

<!--      <el-form-item label="支付宝" prop="zfb">-->
<!--        <el-input-->
<!--          v-model="queryParams.zfb"-->
<!--          placeholder="请输入支付宝"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="微信" prop="wx">-->
<!--        <el-input-->
<!--          v-model="queryParams.wx"-->
<!--          placeholder="请输入微信"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="现金" prop="cash">-->
<!--        <el-input-->
<!--          v-model="queryParams.cash"-->
<!--          placeholder="请输入现金"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="刷卡" prop="creditCard">-->
<!--        <el-input-->
<!--          v-model="queryParams.creditCard"-->
<!--          placeholder="请输入刷卡"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="转账" prop="transfer">-->
<!--        <el-input-->
<!--          v-model="queryParams.transfer"-->
<!--          placeholder="请输入转账"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="优惠" prop="preferential">-->
<!--        <el-input-->
<!--          v-model="queryParams.preferential"-->
<!--          placeholder="请输入优惠"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="实收" prop="paid">-->
<!--        <el-input-->
<!--          v-model="queryParams.paid"-->
<!--          placeholder="请输入实收"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="缴费备注" prop="paymentRemarks">-->
<!--        <el-input-->
<!--          v-model="queryParams.paymentRemarks"-->
<!--          placeholder="请输入缴费备注"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['school:archives:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['school:archives:edit']"
        >修改
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['school:archives:remove']"
        >删除
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['school:archives:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="archivesList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <!--      <el-table-column label="学员档案录入" align="center" prop="id" hidden=""/>-->
      <el-table-column label="学员姓名" align="center" prop="learnerName"/>
      <el-table-column label="电话号" align="center" width="150" prop="iphone"/>
      <!--      <el-table-column label="民族" align="center" prop="nationality"/>-->
      <el-table-column label="性别" align="center" prop="gender">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_user_sex" :value="scope.row.gender"/>
        </template>
      </el-table-column>
      <el-table-column label="证件类型" align="center" prop="documentType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.document_type" :value="scope.row.documentType"/>
        </template>
      </el-table-column>
      <el-table-column label="证件号码" align="center" width="180" prop="documentNumber"/>
      <el-table-column label="出生日期" align="center" prop="dateOfBirth" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.dateOfBirth, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <!--      <el-table-column label="身份证地址" align="center" prop="documentAddress"/>-->
      <!--      <el-table-column label="居住地址" align="center" prop="residentialAddress"/>-->
      <el-table-column label="报名时间" align="center" prop="registrationTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.registrationTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="档案归属" align="center" prop="fileAttribution">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.file_attribution" :value="scope.row.fileAttribution"/>
        </template>
      </el-table-column>

      <el-table-column label="介绍人" align="center" prop="sysUser.nickName"/>

      <el-table-column label="报名点" align="center" prop="registrationLocation">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.registration_location" :value="scope.row.registrationLocation"/>
        </template>
      </el-table-column>
      <el-table-column label="业务类型" align="center" prop="serviceType">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.service_type" :value="scope.row.serviceType"/>
        </template>
      </el-table-column>
      <el-table-column label="报名车型" align="center" prop="registeredModels">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.registered_models" :value="scope.row.registeredModels"/>
        </template>
      </el-table-column>

      <el-table-column label="班制" align="center" prop="classTpye.className"/>

      <el-table-column label="招生来源" align="center" prop="sourceOfEnrollment">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.source_of_enrollment" :value="scope.row.sourceOfEnrollment"/>
        </template>
      </el-table-column>
      <el-table-column label="支付宝" align="center" prop="zfb"/>
      <el-table-column label="微信" align="center" prop="wx"/>
      <el-table-column label="现金" align="center" prop="cash"/>
      <el-table-column label="刷卡" align="center" prop="creditCard"/>
      <el-table-column label="转账" align="center" prop="transfer"/>
      <!--      <el-table-column label="优惠" align="center" prop="preferential"/>-->
      <!--      <el-table-column label="实收" align="center" prop="paid"/>-->
      <!--      <el-table-column label="缴费备注" align="center" prop="paymentRemarks"/>-->
      <el-table-column label="考试状态" align="center" prop="examStatusName"/>
      <!--      <el-table-column label="备注" align="center" prop="remark"/>-->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['school:archives:edit']"
          >修改
          </el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['school:archives:remove']"
          >删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 添加或修改学员档案对话框 -->
    <el-dialog :title="title" :close-on-click-modal="false" :visible.sync="open" v-bind="$attrs" v-on="$listeners" append-to-body>
      <el-row :gutter="15">
        <el-form ref="form" :model="form" :rules="rules" size="medium" label-width="100px"
                 label-position="top">

          <el-col :span="5">
            <el-form-item label="学员姓名" prop="learnerName">
              <el-input v-model="form.learnerName" placeholder="请输入学员姓名" clearable
                        :style="{width: '100%'}"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="7">
            <el-form-item label="手机号" prop="iphone">
              <el-input v-model="form.iphone" placeholder="请输入手机号" :maxlength="11" show-word-limit
                        clearable prefix-icon='el-icon-mobile' :style="{width: '100%'}"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="民族" prop="nationality">
              <el-input v-model="form.nationality" placeholder="请输入民族" clearable
                        :style="{width: '100%'}"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="7">
            <el-form-item label="性别" prop="gender">
              <el-radio-group v-model="form.gender">
                <el-radio
                  v-for="dict in dict.type.sys_user_sex"
                  :key="dict.value"
                  :label="dict.value"
                >{{ dict.label }}
                </el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>


          <el-col :span="6">
            <el-form-item label="证件类型" prop="documentType">
              <el-select v-model="form.documentType" placeholder="请选择证件类型" clearable
                         :style="{width: '100%'}">
                <el-option
                  v-for="dict in dict.type.document_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="parseInt(dict.value)"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>


          <el-col :span="6">
            <el-form-item label="证件号码" label-width="120px" prop="documentNumber">
              <el-input v-model="form.documentNumber" placeholder="请输入证件号码" clearable
                        :style="{width: '100%'}"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="出生日期" prop="dateOfBirth">
              <el-date-picker clearable
                              v-model="form.dateOfBirth"
                              type="date"
                              value-format="yyyy-MM-dd"
                              :style="{width: '100%'}"
                              placeholder="请选择出生日期" clearable>
              </el-date-picker>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="报名时间" prop="registrationTime">
              <el-date-picker clearable
                              v-model="form.registrationTime"
                              type="date"
                              value-format="yyyy-MM-dd"
                              :style="{width: '100%'}"
                              placeholder="请选择报名时间" clearable>
              </el-date-picker>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="身份证地址" prop="documentAddress">
              <el-input v-model="form.documentAddress" placeholder="请输入身份证地址" clearable
                        :style="{width: '100%'}"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="居住地址" prop="residentialAddress">
              <el-input v-model="form.residentialAddress" placeholder="请输入居住地址" clearable
                        :style="{width: '100%'}"></el-input>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="档案归属" prop="fileAttribution">
              <el-select v-model="form.fileAttribution" placeholder="请选择档案归属" clearable
                         :style="{width: '100%'}">
                <el-option
                  v-for="dict in dict.type.file_attribution"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <!--        班制id -->
          <el-col :span="6">
            <el-form-item label="班制" prop="classTypeId">
              <el-select v-model="form.classTypeId" placeholder="请选择班制" @change="selectClassTpye" clearable
                         :style="{width: '100%'}">
                <el-option
                  v-for="item in classTypeList"
                  :key="item.id"
                  :label="`${item.className}(${item.price})`"
                  :value="item.id">
                  <span style="float: left">{{ item.className }}</span>
                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.price + '元' }}</span>

                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="介绍人" prop="userId">
              <el-select v-model="form.userId" placeholder="请选择介绍人" clearable :style="{width: '100%'}">
                <el-option
                  v-for="item in userList"
                  :key="item.userId"
                  :label="`${item.nickName}(${item.phonenumber})`"
                  :value="item.userId">
                  <span style="float: left">{{ item.nickName }}</span>
                  <span style="float: right; color: #8492a6; font-size: 13px">{{ item.phonenumber }}</span>
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="报名点" prop="registrationLocation">
              <el-select v-model="form.registrationLocation" placeholder="请选择报名点" clearable
                         :style="{width: '100%'}">
                <el-option
                  v-for="dict in dict.type.registration_location"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="业务类型" prop="serviceType">
              <el-select v-model="form.serviceType" placeholder="请选择业务类型" clearable
                         :style="{width: '100%'}">
                <el-option
                  v-for="dict in dict.type.service_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="报名车型" prop="registeredModels">
              <el-select v-model="form.registeredModels" placeholder="请选择报名车型" clearable
                         :style="{width: '100%'}">
                <el-option
                  v-for="dict in dict.type.registered_models"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="招生来源" prop="sourceOfEnrollment">
              <el-select v-model="form.sourceOfEnrollment" placeholder="请选择招生来源" clearable
                         :style="{width: '100%'}">
                <el-option
                  v-for="dict in dict.type.source_of_enrollment"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>


          <el-col :span="6">
            <el-form-item label="支付宝" prop="zfb">
              <el-input v-model="form.zfb" placeholder="请选择支付宝" clearable :style="{width: '100%'}">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="微信" prop="wx">
              <el-input v-model="form.wx" placeholder="请选择微信" clearable :style="{width: '100%'}">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="刷卡" prop="creditCard">
              <el-input v-model="form.creditCard" placeholder="请选择刷卡" clearable :style="{width: '100%'}">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="转账" prop="transfer">
              <el-input v-model="form.transfer" placeholder="请选择转账" clearable :style="{width: '100%'}">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="实收" prop="paid">
              <el-input :value="totalPrice" placeholder="请输入实收" disabledx clearable
                        :style="{width: '100%'}"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="优惠" prop="preferential">
              <el-input :value="preferentialPrice" placeholder="请输入优惠" disabledx clearable
                        :style="{width: '100%'}"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="缴费备注" prop="paymentRemarks">
              <el-input v-model="form.paymentRemarks" type="textarea" placeholder="请输入缴费备注"
                        :autosize="{minRows: 4, maxRows: 4}" :style="{width: '100%'}"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" type="textarea" placeholder="请输入备注"
                        :autosize="{minRows: 4, maxRows: 4}" :style="{width: '100%'}"></el-input>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
    <!--    <el-dialog :title="title" :visible.sync="open" width="1000px" append-to-body>-->
    <!--      <el-form ref="form" :model="form" :rules="rules" label-width="80px">-->
    <!--        <el-form-item label="学员姓名" prop="learnerName">-->
    <!--          <el-input v-model="form.learnerName" placeholder="请输入学员姓名"/>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="电话号" prop="iphone">-->
    <!--          <el-input v-model="form.iphone" placeholder="请输入电话号"/>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="民族" prop="nationality">-->
    <!--          <el-input v-model="form.nationality" placeholder="请输入民族"/>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="性别" prop="gender">-->
    <!--          <el-radio-group v-model="form.gender">-->
    <!--            <el-radio-->
    <!--              v-for="dict in dict.type.sys_user_sex"-->
    <!--              :key="dict.value"-->
    <!--              :label="dict.value"-->
    <!--            >{{ dict.label }}-->
    <!--            </el-radio>-->
    <!--          </el-radio-group>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="证件类型" prop="documentType">-->
    <!--          <el-select v-model="form.documentType" placeholder="请选择证件类型">-->
    <!--            <el-option-->
    <!--              v-for="dict in dict.type.document_type"-->
    <!--              :key="dict.value"-->
    <!--              :label="dict.label"-->
    <!--              :value="parseInt(dict.value)"-->
    <!--            ></el-option>-->
    <!--          </el-select>-->
    <!--        </el-form-item>-->

    <!--        <el-form-item label="证件号码" label-width="120px" prop="documentNumber">-->
    <!--          <el-input v-model="form.documentNumber" placeholder="请输入证件号码"/>-->
    <!--        </el-form-item>-->

    <!--        <el-form-item label="出生日期" prop="dateOfBirth">-->
    <!--          <el-date-picker clearable-->
    <!--                          v-model="form.dateOfBirth"-->
    <!--                          type="date"-->
    <!--                          value-format="yyyy-MM-dd"-->
    <!--                          placeholder="请选择出生日期">-->
    <!--          </el-date-picker>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="身份证地址" prop="documentAddress">-->
    <!--          <el-input v-model="form.documentAddress" placeholder="请输入身份证地址"/>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="居住地址" prop="residentialAddress">-->
    <!--          <el-input v-model="form.residentialAddress" placeholder="请输入居住地址"/>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="报名时间" prop="registrationTime">-->
    <!--          <el-date-picker clearable-->
    <!--                          v-model="form.registrationTime"-->
    <!--                          type="date"-->
    <!--                          value-format="yyyy-MM-dd"-->
    <!--                          placeholder="请选择报名时间">-->
    <!--          </el-date-picker>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="档案归属" prop="fileAttribution">-->
    <!--          <el-select v-model="form.fileAttribution" placeholder="请选择档案归属">-->
    <!--            <el-option-->
    <!--              v-for="dict in dict.type.file_attribution"-->
    <!--              :key="dict.value"-->
    <!--              :label="dict.label"-->
    <!--              :value="dict.value"-->
    <!--            ></el-option>-->
    <!--          </el-select>-->
    <!--        </el-form-item>-->
    <!--        &lt;!&ndash;        班制id &ndash;&gt;-->
    <!--        <el-form-item label="班制" prop="classTypeId">-->
    <!--          <el-select v-model="form.classTypeId" placeholder="请选择班制" @change="selectClassTpye">-->
    <!--            <el-option-->
    <!--              v-for="item in classTypeList"-->
    <!--              :key="item.id"-->
    <!--              :label="`${item.className}(${item.price})`"-->
    <!--              :value="item.id">-->
    <!--              <span style="float: left">{{ item.className }}</span>-->
    <!--              <span style="float: right; color: #8492a6; font-size: 13px">{{ item.price + '元' }}</span>-->

    <!--            </el-option>-->
    <!--          </el-select>-->
    <!--        </el-form-item>-->

    <!--        <el-form-item label="介绍人" prop="userId">-->
    <!--          <el-select v-model="form.userId" placeholder="请选择介绍人">-->
    <!--            <el-option-->
    <!--              v-for="item in userList"-->
    <!--              :key="item.userId"-->
    <!--              :label="`${item.nickName}(${item.phonenumber})`"-->
    <!--              :value="item.userId">-->
    <!--              <span style="float: left">{{ item.nickName }}</span>-->
    <!--              <span style="float: right; color: #8492a6; font-size: 13px">{{ item.phonenumber }}</span>-->
    <!--            </el-option>-->
    <!--          </el-select>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="报名点" prop="registrationLocation">-->
    <!--          <el-select v-model="form.registrationLocation" placeholder="请选择报名点">-->
    <!--            <el-option-->
    <!--              v-for="dict in dict.type.registration_location"-->
    <!--              :key="dict.value"-->
    <!--              :label="dict.label"-->
    <!--              :value="dict.value"-->
    <!--            ></el-option>-->
    <!--          </el-select>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="业务类型" prop="serviceType">-->
    <!--          <el-select v-model="form.serviceType" placeholder="请选择业务类型">-->
    <!--            <el-option-->
    <!--              v-for="dict in dict.type.service_type"-->
    <!--              :key="dict.value"-->
    <!--              :label="dict.label"-->
    <!--              :value="dict.value"-->
    <!--            ></el-option>-->
    <!--          </el-select>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="报名车型" prop="registeredModels">-->
    <!--          <el-select v-model="form.registeredModels" placeholder="请选择报名车型">-->
    <!--            <el-option-->
    <!--              v-for="dict in dict.type.registered_models"-->
    <!--              :key="dict.value"-->
    <!--              :label="dict.label"-->
    <!--              :value="dict.value"-->
    <!--            ></el-option>-->
    <!--          </el-select>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="招生来源" prop="sourceOfEnrollment">-->
    <!--          <el-select v-model="form.sourceOfEnrollment" placeholder="请选择招生来源">-->
    <!--            <el-option-->
    <!--              v-for="dict in dict.type.source_of_enrollment"-->
    <!--              :key="dict.value"-->
    <!--              :label="dict.label"-->
    <!--              :value="dict.value"-->
    <!--            ></el-option>-->
    <!--          </el-select>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="支付宝" prop="zfb" @change="handleEdit">-->
    <!--          <el-input v-model="form.zfb" placeholder="请输入支付宝"/>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="微信" prop="wx">-->
    <!--          <el-input v-model="form.wx" placeholder="请输入微信"/>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="现金" prop="cash">-->
    <!--          <el-input v-model="form.cash" placeholder="请输入现金"/>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="刷卡" prop="creditCard">-->
    <!--          <el-input v-model="form.creditCard" placeholder="请输入刷卡"/>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="转账" prop="transfer">-->
    <!--          <el-input v-model="form.transfer" placeholder="请输入转账"/>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="优惠" prop="preferential">-->
    <!--          <el-input :value="preferentialPrice" placeholder="请输入优惠" disabledx/>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="实收" prop="paid">-->
    <!--          <el-input :value="totalPrice" placeholder="请输入实收" disabledx/>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="缴费备注" prop="paymentRemarks">-->
    <!--          <el-input v-model="form.paymentRemarks" placeholder="请输入缴费备注"/>-->
    <!--        </el-form-item>-->
    <!--        <el-form-item label="备注" prop="remark">-->
    <!--          <el-input v-model="form.remark" placeholder="请输入备注"/>-->
    <!--        </el-form-item>-->
    <!--      </el-form>-->
    <!--      <div slot="footer" class="dialog-footer">-->
    <!--        <el-button type="primary" @click="submitForm">确 定</el-button>-->
    <!--        <el-button @click="cancel">取 消</el-button>-->
    <!--      </div>-->
    <!--    </el-dialog>-->
  </div>
</template>

<script>
import {listArchives, getArchives, delArchives, addArchives, updateArchives} from "@/api/school/archives";
import {listTpye} from "@/api/school/tpye";
import {listUser} from "@/api/system/user";

export default {
  name: "Archives",
  dicts: ['file_attribution', 'registered_models', 'source_of_enrollment', 'document_type', 'registration_location', 'sys_user_sex', 'service_type'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 学员档案表格数据
      archivesList: [],
      //班制数据
      classTypeList: [],
      //介绍人数据
      userList: [],
      //当前班制的价格
      classPrice: 0,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 备注时间范围
      daterangeDateOfBirth: [],
      // 备注时间范围
      daterangeRegistrationTime: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        learnerName: null,
        iphone: null,
        nationality: null,
        gender: null,
        documentType: null,
        documentNumber: null,
        dateOfBirth: null,
        residentialAddress: null,
        registrationTime: null,
        fileAttribution: null,
        userId: null,
        registeredModels: null,
        classTypeId: null,
        sourceOfEnrollment: null,
        zfb: null,
        wx: null,
        cash: null,
        creditCard: null,
        transfer: null,
        preferential: null,
        paid: null,
        paymentRemarks: null,
        examStatus: null,
      },
      // 表单参数
      form: {
        cash: 0,
        zfb: 0,
        wx: 0,
        creditCard: 0,
        transfer: 0,
        preferential: 0
      },
      // 表单校验
      rules: {
        learnerName: [
          {required: true, message: "学员姓名不能为空", trigger: "blur"}
        ],
        iphone: [
          {required: true, message: "电话号不能为空", trigger: "blur"}
        ],
        gender: [
          {required: true, message: "性别不能为空", trigger: "change"}
        ],
        documentType: [
          {required: true, message: "证件类型不能为空", trigger: "change"}
        ],
        documentNumber: [
          {required: true, message: "证件号码不能为空", trigger: "blur"}
        ],
        dateOfBirth: [
          {required: true, message: "出生日期不能为空", trigger: "blur"}
        ],
        documentAddress: [
          {required: true, message: "身份证地址不能为空", trigger: "blur"}
        ],
        registrationTime: [
          {required: true, message: "报名时间不能为空", trigger: "blur"}
        ],
        fileAttribution: [
          {required: true, message: "档案归属不能为空", trigger: "change"}
        ],
        userId: [
          {required: true, message: "介绍人id不能为空", trigger: "blur"}
        ],
        registrationLocation: [
          {required: true, message: "报名点不能为空", trigger: "change"}
        ],
        registeredModels: [
          {required: true, message: "报名车型不能为空", trigger: "change"}
        ],
        classTypeId: [
          {required: true, message: "班制id不能为空", trigger: "change"}
        ],
      }
    };
  },
  computed: {
    totalPrice() {
      return Number(this.form.cash) + Number(this.form.zfb) + Number(this.form.wx) + Number(this.form.creditCard) + Number(this.form.transfer)
    },
    preferentialPrice() {
      return this.classPrice - (Number(this.form.cash) + Number(this.form.zfb) + Number(this.form.wx) + Number(this.form.creditCard) + Number(this.form.transfer))
    }
  },
  created() {
    this.getList();
    this.getClassList();
    this.getUserList();
  },
  methods: {
    // 在 Input 值改变时触发
    handleEdit(e) {
      let value = e.replace(/[^\d]/g, ""); // 只能输入数字
      value = value.replace(/^0+(\d)/, "$1"); // 第一位0开头，0后面为数字，则过滤掉，取后面的数字
      value = value.replace(/(\d{15})\d*/, '$1') // 最多保留15位整数
      this.height = value
    },
    /** 查询学员档案列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeDateOfBirth && '' != this.daterangeDateOfBirth) {
        this.queryParams.params["beginDateOfBirth"] = this.daterangeDateOfBirth[0];
        this.queryParams.params["endDateOfBirth"] = this.daterangeDateOfBirth[1];
      }
      if (null != this.daterangeRegistrationTime && '' != this.daterangeRegistrationTime) {
        this.queryParams.params["beginRegistrationTime"] = this.daterangeRegistrationTime[0];
        this.queryParams.params["endRegistrationTime"] = this.daterangeRegistrationTime[1];
      }
      listArchives(this.queryParams).then(response => {
        this.archivesList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    selectClassTpye(value) {
      let opt = {};
      opt = this.classTypeList.find((item) => {
        return item.id === value;
      });
      this.classPrice = opt.price;
      console.log(this.classPrice)
    },
    /** 查询班级列表 */
    getClassList() {
      listTpye().then(response => {
        this.classTypeList = response.rows;
      });
    },
    /** 查询班级列表 */
    getUserList() {
      listUser().then(response => {
        this.userList = response.rows;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        learnerName: null,
        iphone: null,
        nationality: null,
        gender: null,
        documentType: null,
        documentNumber: null,
        dateOfBirth: null,
        documentAddress: null,
        residentialAddress: null,
        registrationTime: null,
        fileAttribution: null,
        userId: null,
        registrationLocation: null,
        serviceType: null,
        registeredModels: null,
        classTypeId: null,
        sourceOfEnrollment: null,
        zfb: null,
        wx: null,
        cash: null,
        creditCard: null,
        transfer: null,
        preferential: null,
        paid: null,
        paymentRemarks: null,
        examStatus: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeDateOfBirth = [];
      this.daterangeRegistrationTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加学员档案";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids

      getArchives(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改学员档案";
        this.selectClassTpye(response.data.classTypeId)
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updateArchives(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addArchives(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除学员档案编号为"' + ids + '"的数据项？').then(function () {
        return delArchives(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('school/archives/export', {
        ...this.queryParams
      }, `archives_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
